#!/usr/bin/env python3

if __name__ == '__main__':
    import os, sys
    import matplotlib.pyplot as plt

    arguments = sys.argv[1:]
    lr_file = arguments[0]

    if not os.path.exists(lr_file):
        print(f'{lr_file} not found')
        exit(0)

    steps = []
    lrs = []
    with open(lr_file, 'r') as f:
        for line in f:
            if not line:
                continue
            # line: (2025-03-19 18:15:30) step=159,lr=2.159680442248444e-05
            # data: 159,lr=2.159680442248444e-05
            data = line.split('step=')[-1]
            # [159, 2.159680442248444e-05]
            data = data.split(',lr=')

            step = int(data[0])
            lr = float(data[1])

            if step in steps:
                continue

            steps.append(step)
            lrs.append(lr)

    plt.xlabel('steps')
    plt.ylabel('lr')

    plt.plot(steps, lrs)
    plt.show()


